/* 删除有序数组的重复项 */

#include <stdio.h>

#define BUFFER_SIZE 10
int removeDuplicates(int* nums, int numsSize)
{
    if(nums == NULL)
    {
        return 0;
    }

    if(numsSize <= 1)
    {
        return numsSize;
    }
    int pos = 1;
    for (int idx = 1; idx < numsSize; idx++)
    {
        if(nums[idx -1] != nums[idx])
        {
            /* 后置++*/
            nums[pos++] = nums[idx];

        }
    }


    return pos;
}

int main()
{
    int nums[] = {0, 0, 1, 1, 1, 2, 2, 3, 3, 4};

    int newSize = removeDuplicates(nums, sizeof(nums) / sizeof(nums[0]));
    printf("newSize:%d\n", newSize);
    for(int idx = 0; idx < newSize; idx++)
    {
        printf("%d\n", nums[idx]);
    }
    return 0;
}